Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safer task ids #47

Merged
merged 3 commits into from
Aug 11, 2020
Merged

Safer task ids #47

merged 3 commits into from
Aug 11, 2020

Conversation

alexreardon
Copy link
Collaborator

@alexreardon alexreardon commented Aug 7, 2020

We previously used taskId as a way to link a task with it's result stored in localStorage.

However, taskId was essentially an index value and we could only ever add new tasks to the end of existing ones. This PR moves over to using the task.name as the unique key.

Pros:

  • Can reorder tasks safely
  • Can add new tasks in any position
  • Easier to parse result values stored in local storage

Cons:

  • Task name becomes API. If we change a task name then pinned results will no longer match
  • We can get tasks with duplicate task names. Mitigation: I wrote some code to throw an error if a duplicate is found
  • This is a change in format for stored pinned values. Existing pins won't be able to be imported. We are not on stable versions yet so I think this is fine

I think on balance using the task.name is the better path for now. We could look at doing something more sophisticated in the future if we need to

@alexreardon alexreardon requested a review from AndrewOCC August 7, 2020 06:22
Copy link
Contributor

@AndrewOCC AndrewOCC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me! Love that there's an upgrade path and appropriate warnings for users who have saved storage between versions, sweating the details!

@alexreardon alexreardon merged commit f698b61 into master Aug 11, 2020
@alexreardon alexreardon deleted the safer-task-ids branch August 11, 2020 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants